package net.tools.web;


import java.io.*;
import java.math.*;
import java.security.*;
import java.security.spec.*;

import org.apache.commons.pool.impl.*;

class ApplicationProcessor
{

	static final Integer TUNNEL_COMMAND = Integer.valueOf(1);

	static final Integer TUNNEL_RESPONSE = Integer.valueOf(2);

	static final Integer RSA_CIPHER = Integer.valueOf(3);

	static final Integer AES_CIPHER = Integer.valueOf(4);

	static final Integer SHA1_MD = Integer.valueOf(5);

	static final Integer SEC_RAND = Integer.valueOf(6);

	private StackKeyedObjectPool objPool = new StackKeyedObjectPool();

	private PrivateKey priKey;

	ApplicationProcessor(BigInteger modulus, BigInteger privateExponent) throws NoSuchAlgorithmException, InvalidKeySpecException
	{
		priKey = KeyFactory.getInstance("RSA").generatePrivate(new RSAPrivateKeySpec(modulus, privateExponent));
	}

	StackKeyedObjectPool getObjPool()
	{
		return objPool;
	}

	SessionProcessor startSession(InputStream in, OutputStream out) throws Exception
	{
		SessionProcessor sessProc = new SessionProcessor();
		sessProc.init(priKey, in, out, objPool);
		return sessProc;
	}

}
